﻿using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using OnlineCourse.JWTAuthorizePolicy;
using OnlineCourse.Model;
using OnlineCourse.Model.Entity;

namespace OnlineCourse.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TeacherController : ControllerBase
    {
        private readonly PermissionRequirement _requirement;
        private readonly Services.TeacherService _usbll;
        public TeacherController(ApplicationDbContext db, PermissionRequirement requirement)
        {

            _requirement = requirement;
            _usbll = new Services.TeacherService(db);
        }
        /// <summary>
        /// 添加老师信息
        /// </summary>
        /// <param name="name"></param>
        /// <param name="headImage"></param>
        /// <param name="intro"></param>
        /// <returns></returns>
        [HttpPost("Add")]
        public IActionResult Add(string name, string headImage, string intro)
        {
            bool mark = _usbll.Add(name,headImage ,intro);

            return Ok(mark);
        }
        /// <summary>
        /// 更新老师信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="headImage"></param>
        /// <param name="intro"></param>
        /// <returns></returns>
        [HttpPut("Update")]
        public IActionResult Update(Guid id, string name, string headImage, string intro)
        {
            bool mark = _usbll.Update(id, name, headImage, intro);
            return Ok(mark);
        }
        /// <summary>
        /// 查询老师信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("GetList")]
        public IActionResult GetList(Guid id)
        {
            var list = _usbll.GetList(id);
            return Ok(list);
        }
        /// <summary>
        /// 删除老师信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete ("Delete")]
        public IActionResult Delete(Guid id)
        {
            bool mark = _usbll.Delete(id);
            return Ok(mark);
        }
    }
}